package com.king.security.ctrl;

import com.king.security.base.Result;
import com.king.security.entity.MyUser;
import com.king.security.model.UserDto;
import com.king.security.service.UserService;
import com.king.security.target.MyAuthentication;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author KING
 * @date 2018/8/30 17:52
 */
@RestController
@RequestMapping(value = "/back/user")
@Slf4j
public class UserBackControl {


    @Autowired
    public UserService userService;

    @MyAuthentication(required = false)
    @PostMapping(value = "test")
    public Result test(@RequestBody UserDto user) {
        String userName = user.getUserName();
        System.out.println("测试结果---" + userName);
        return Result.buildSuccess(user);
    }

    @PostMapping(value = "add")
    public MyUser add(@RequestBody MyUser user) {
        return userService.add(user);
    }

}